#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
class Name_pairs
{
public:
    Name_pairs() {}
    Name_pairs(int n) : _name_ages(n) {}
    void read_names(std::istream &in);
    void read_ages(std::istream &in);
    void print(std::ostream &out) const;
    void sort();

private:
    int n;
    std::vector<std::pair<std::string, double>> _name_ages;
};

void Name_pairs::read_names(std::istream &in)
{
    printf("请输入每个用户的名字：");
    for (auto &e : _name_ages)
    {
        in >> e.first;
    }
}

void Name_pairs::read_ages(std::istream &in)
{
    printf("请输入每个用户的年龄：");
    for (auto &e : _name_ages)
    {
        in >> e.second;
    }
}

void Name_pairs::print(std::ostream &out) const
{
    for (auto &e : _name_ages)
    {
        out << '(' << e.first << ',' << e.second << ')' << std::endl;
    }
}

void Name_pairs::sort()
{
    std::sort(_name_ages.begin(), _name_ages.end());
}

std::ostream &operator<<(std::ostream &out, const Name_pairs &p)
{
    p.print(out);
    return out;
}